package br.com.ozsolucoes.entity;

import java.io.Serializable;

import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "Servico_Categoria")
public class ServicoCategoria implements Serializable {

	private static final long serialVersionUID = 1L;

	public ServicoCategoria() {
		super();
	}

	@EmbeddedId
	private ServicoCategoriaPK pk;

	@ManyToOne
	@JoinColumn(name = "idServico", referencedColumnName = "id",insertable = false , updatable = false)
	private Servico servico;

	@ManyToOne
	@JoinColumn(name = "idCategoria", referencedColumnName = "id",insertable = false, updatable = false)
	private Categoria categoria;

	public ServicoCategoriaPK getPk() {
		return pk;
	}

	public void setPk(ServicoCategoriaPK pk) {
		this.pk = pk;
	}

	public Servico getServico() {
		return servico;
	}

	public void setServico(Servico servico) {
		this.servico = servico;
	}

	public Categoria getCategoria() {
		return categoria;
	}

	public void setCategoria(Categoria categoria) {
		this.categoria = categoria;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((categoria == null) ? 0 : categoria.hashCode());
		result = prime * result + ((pk == null) ? 0 : pk.hashCode());
		result = prime * result + ((servico == null) ? 0 : servico.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ServicoCategoria other = (ServicoCategoria) obj;
		if (categoria == null) {
			if (other.categoria != null)
				return false;
		} else if (!categoria.equals(other.categoria))
			return false;
		if (pk == null) {
			if (other.pk != null)
				return false;
		} else if (!pk.equals(other.pk))
			return false;
		if (servico == null) {
			if (other.servico != null)
				return false;
		} else if (!servico.equals(other.servico))
			return false;
		return true;
	}

}
